package cn.wsw.hrm.controller;

import cn.wsw.hrm.constants.SmsContants;
import cn.wsw.hrm.service.ISmsService;
import cn.wsw.hrm.util.AjaxResult;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/sms")
public class SmsController {
        @Autowired
        private ISmsService smsService;
        //1 以下两个放到常量类中
        //Uid=本站用户名
        //Key=接口安全秘钥
        //2 以下两个是动态传入
        // smsMob=手机号码&smsText=验证码:8888
        @PostMapping
        AjaxResult send(@RequestBody String params){
            Map<String,String> paramsTmp =
                    JSONObject.parseObject(params,Map.class);
            //封装参数
            paramsTmp.put("Uid", SmsContants.SMS_UID);
            paramsTmp.put("Key", SmsContants.SMS_KEY);
            return smsService.sendSmsCode(paramsTmp);
        }
}
